# koroFileHeader at Yungoal acer
# Create: 2021-04-25 18:13:36
# LastEdit: 2021-04-26 13:47:50
"""说明暂无"""
__author__ = '749B'


import unittest

if __name__ == '__main__':
    import os
    import sys
    sys.path.append(os.getcwd())
# pylint: disable = import-error
from azure_client.data_format import recovery_vault_name


class RecoveryVaultNameTestCase(unittest.TestCase):

    def test_recovery_vault_name(self):
        key = 'policyId'
        befor = []
        after = []

        befor.append({
            'name': 'server1', 
            key: ''
        })
        after.append({
            'name': 'server1', 
            'RecoveryVaultName': ''
        })

        befor.append({
            'name': 'DB1',
            key: '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' \
                '/resourceGroups/Default-Group' \
                '/providers/microsoft.recoveryservices' \
                '/Vaults/Vault-VM-DB' \
                '/backupPolicies/finalback3day-4am'
        })
        after.append({
            'name': 'DB1',
            'RecoveryVaultName': 'Vault-VM-DB'
        })

        befor.append({
            'name': 'DB2',
            key: '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' \
                '/resourceGroups/Wechat-Group' \
                '/providers/Microsoft.RecoveryServices' \
                '/vaults/finalback3day' \
                '/backupPolicies/finalback3day-2am'
        })
        after.append({
            'name': 'DB2',
            'RecoveryVaultName': 'finalback3day'
        })

        recovery_vault_name(befor, key)
        self.assertEqual(befor, after)


if __name__ == '__main__':
    unittest.main()
